import os
import torch
from transformers import AutoTokenizer, AutoModel
from sentence_transformers import SentenceTransformer

def download_model():
    """下载BGE-M3模型到本地"""
    print("开始下载BGE-M3模型...")
    
    # 创建模型目录
    model_dir = os.path.join(os.path.dirname(__file__), "models", "bge-m3")
    os.makedirs(model_dir, exist_ok=True)
    
    # 下载模型
    model = SentenceTransformer('BAAI/bge-m3')
    
    # 保存模型到本地
    model.save(model_dir)
    print(f"模型已保存到: {model_dir}")

if __name__ == "__main__":
    download_model() 